/**
 * 创建virtual DOM对象
 * @param {String} type 
 * @param {Object} props 
 * @param  {...any} children 
 */
export default function createElement(type, props, ...children) {
    const childElements = [...children].reduce((result, child) => {
        if (child !== false && child !== true && child !== null) {
            if (child instanceof Object) {
                result.push(child);
            } else {
                // 将文本节点转换为对象
                result.push(createElement('text', { textContent: child }));
            }
        }
        return result;
    }, []);
    // 返回virtual DOM对象
    return {
        type,
        props: Object.assign({ children: childElements}, props),
        children: childElements
    };
};  